package com.lwz.laboratory.controller;


import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import com.lwz.laboratory.entity.Archivses;
import com.lwz.laboratory.entity.Recruitplan;
import com.lwz.laboratory.entity.Workcontent;
import com.lwz.laboratory.service.ArchivsesService;
import com.lwz.laboratory.service.WorkcontentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.text.Document;
import java.util.List;

@Controller
public class WorkcontentController {
    @Autowired
    WorkcontentService workcontentService;

    @Autowired
    ArchivsesService archivsesService;

    @RequestMapping("/torecordwork")
    public String toAddwork(String stuid,Model model){
        Archivses archivses = archivsesService.selectBystuid(stuid);
        String a =archivses.getArchivesid().toString();
        List<Workcontent> workcontents =workcontentService.findbyassid(a);
        model.addAttribute("workcontents",workcontents);

        return "work/work_onelist";
    }



    @GetMapping("/worklist")
    public String worklist(Model model, HttpServletRequest request){
        String worktime = request.getParameter("context");
        List<Workcontent> list= workcontentService.findbyworktime(worktime);
        model.addAttribute("worklist",list);
        return "/work/work_list";

    }

    @RequestMapping("/toworkadd")
    public String toaddwork(){
        return "work/work_record";
    }


    @RequestMapping("/workcontentadd")
    public String Addwork(String stuid,Workcontent workcontent,Model model){

        //通过学号查找人员编号
        Archivses archivses = archivsesService.selectBystuid(workcontent.getAssistantid());
        String a =archivses.getArchivesid().toString();
        workcontent.setAssistantid(a);
        workcontentService.addworkcontent(workcontent);
        return toAddwork(stuid,model);
    }




}
